import 'package:earn_money/widgets/app_bar.dart';
import 'package:earn_money/widgets/game_icon.dart';
import 'package:earn_money/widgets/icon_list.dart';
import 'package:earn_money/widgets/switch.dart';
import 'package:earn_money/widgets/title_bar.dart';
import 'package:flutter/material.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}


class _MyHomePageState extends State<MyHomePage> {
  
  int _selectedIndex = 0;
  
  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

   static const List<String> _appBarTitles = <String>[
    '',
    '热门',
    '兑换',
    '邀请',
  ];

  @override
  Widget build(BuildContext context) {
    
    var gradientAppBar = GradientAppBar(
      title: _appBarTitles[_selectedIndex],
      height: 100,
      gradient:const LinearGradient(
        colors: [Colors.blue, Colors.purple],
      ),
    );
      
    var listview = ListView(
        children: const <Widget>[
          GameIconList(),
          CustomWidget(image: 'http://192.168.1.185/1.jpg', name: 'hello world!', money: '10200',),
          HorizontalIconList(),
          SwitchWidget(),
         
          // Other widgets here
        ],
      );


    return Scaffold(
      appBar:gradientAppBar,
      body:listview,
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: '首页',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.public),
            label: '热门',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.redeem),
            label: '兑换',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.inventory),
            label: '邀请',
          ),
        ],
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.blue[800],
        unselectedItemColor: Colors.grey,
        showSelectedLabels: true,
        showUnselectedLabels: true,
        onTap: _onItemTapped,
      ),
    );
  }
  
}